package com.google.code.stalkernet.async.io;

import java.nio.ByteBuffer;
import java.nio.channels.GatheringByteChannel;

import com.google.code.stalkernet.async.Async;

/**
 * Asynchronous version of {@link GatheringByteChannel} interface.
 *
 * @author Mikhail Vladimirov
 */
public interface AsyncGatheringByteChannel
    extends Async, AsyncWritableByteChannel
{
    /**
     * Asynchronous version of {@link GatheringByteChannel#write(ByteBuffer[],
     * int, int)}.
     *
     * @param srcs The buffers from which bytes are to be retrieved
     * @param offset The offset within the buffer array of the first buffer from
     *        which bytes are to be retrieved; must be non-negative and no
     *        larger than <tt>srcs.length</tt>
     * @param length The maximum number of buffers to be accessed; must be
     *        non-negative and no larger than
     *        <tt>srcs.length</tt>&nbsp;-&nbsp;<tt>offset</tt>
     * @param callback callback to receive asynchronous operation result
     * @return asynchronous operation handle
     */
    public Handle write (
        ByteBuffer[] srcs, int offset, int length, Callback <Long> callback);

    /**
     * Asynchronous version of {@link GatheringByteChannel#write(ByteBuffer[])}.
     *
     * @param srcs The buffers from which bytes are to be retrieved
     * @param callback callback to receive asynchronous operation result
     * @return asynchronous operation handle
     */
    public Handle write(ByteBuffer[] srcs, Callback <Long> callback);
}
